package com.bai.translation;

import java.io.IOException;
import java.nio.file.Paths;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        String existingExcelPath  = "C:\\Users\\1065794\\Desktop\\aa.xlsx";
        String codeBaseDir = "C:\\gitsource\\SelfServeDP\\DataAnalysis\\src\\main\\java";
        String enResourceFilePath  = "C:\\gitsource\\SelfServeDP\\DataAnalysis\\src\\main\\resources\\i18n\\messages_en_us.properties";
        String zhResourceFilePath  = "C:\\gitsource\\SelfServeDP\\DataAnalysis\\src\\main\\resources\\i18n\\messages_zh_cn.properties";
        String untranslatedExcelPath = "C:\\Users\\1065794\\Desktop\\untranslated.xlsx";


        Map<String, String> md5Map = new HashMap<>();
        List<String> untranslated = new ArrayList<>();

        // Load existing translations
        Map<String, String> translations = UntranslatedExcelGenerator.loadTranslationsFromExcel(existingExcelPath);
        // 更新国际化资源文件
        ResourceFileGenerator.updateResourceFiles(enResourceFilePath, zhResourceFilePath, translations);

        // Replace Chinese text in code and collect md5 keys
        CodeReplacer.replaceChineseInAnnotationsAndMethods(codeBaseDir, translations, md5Map, untranslated);

        // Generate resource files
        ResourceFileGenerator.generateResourceFiles(md5Map, zhResourceFilePath, enResourceFilePath, translations);

        // Generate untranslated Excel
        UntranslatedExcelGenerator.generateUntranslatedExcel(untranslated, untranslatedExcelPath);
    }
}

